home *** CD-ROM | disk | FTP | other *** search
- //
- // Two pole, two zero, resonant lowpass filter.
- // Both zeros are at the Nyquist frequency, and the
- // conjugate pole pair can be moved around by selecting
- // the angular frequency (w) and radius (r) of the
- // poles. The filter is normalized at DC.
- //
- // All in all, this is a bad implementation, suffering
- // from a variety of ills. Since coefficients can't be
- // greater than +/- 1.0, the biquad implementation
- // uses multiple FIR taps to get coefficients greater
- // than 1, and is thus really inefficient. Headroom
- // scaling is similarly awkward. Finally, the control
- // using (r,w) is bad since r doesn't have good
- // resolution near 1, and specifying fc and Q would
- // be better. But, it works and is instructional.
- //
- // MIDI ctl 1 -> roughly fc from 32 to 8kHz in log freq
- // MIDI ctl 2 -> radius of poles from 0 to 1 (!)
- //
- // Bill Gardner, March, 1993
- //
- #include "macros.rvb"
- #include "biquad.rvb"
-
- #define PI 3.1415923
- #define w (32 * pow(2,range(ctl(1),0,8)) * 2 * PI / fs)
- #define r init(115/127,ctl(2))
- #define hdrm 16 // 24 dB of headroom
-
- // get monophonic input
- fir(0, Lin, 0.5 / hdrm, Rin, 0.5 / hdrm);
- // DC normalized two pole lowpass
- biquad(0, Lout, (1 - 2*r*cos(w) + r*r) / 4,
- 2*r*cos(w), -r*r, 1, 1, 2);
- // scale output by 8 (18 dB)
- add(Lout,Lout);
- add(Lout,Lout);
- add(Lout,Lout);
- move(Lout,Rout);
-